﻿@{
    ViewData["Title"] = "Home Page";
}

<div class="text-center">
    <h1 class="display-4">Welcome</h1>
    <p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
</div>
@section Scripts{
    <script src="~/lib/signalr.js/jquery.signalR.js"></script>
    <script src="http://127.0.0.1:9000/signalr/hubs"></script>
    <script>
        $(function () {
            $.connection.hub.url = 'http://127.0.0.1:9000/signalr';

            var hub = $.connection.mainHub;

            // 服务端接收到后。回调方法
            // code 状态码
            // docCode 对应传过来的docCode,有些情况下为空
            // message 字符串，返回附加说明消息
            hub.client.callback = function (code, docCode, message) {
                alert(message);
            }

            $.connection.hub.start().done(function () {
                console.log("连接成功");

                var data = {
                    "OptType": 4,
                    "FilePath": "http://localhost:5276/wordTemplate.DOC",
                    "RedPath": "http://localhost:5276/ht.DOC",
                    "VerPath": "http://localhost:5276/bj.DOC",
                    "OpenType": 0
                    , "Params": "{'￥￥FYTFS':'议题1'}"
                    , "User": "com.lm.web.entity.user.AppUser@6fcf2f86",
                    "DocCode": "8e98d24306bd4ec4b154b0294fab0cae",
                    "SessionId": "75F38BDBC6BFEE57F48A1CF54616FCA3",
                    "Token": "ECF91C97DCEA66331881417037495FDE",
                    "UploadPath": "http://localhost:5276/home/upload"
                }
                hub.server.action(data).done(s => {
                    debugger;
                });

                //data.DocCode = "test2";
                //data.SessionId = "test2";
                //hub.server.action(data);
                //data.DocCode = "test3";
                //data.SessionId = "test3";
                //hub.server.action(data);
                //data.DocCode = "test4";
                //data.SessionId = "test4";
                //hub.server.action(data);

                //文件是否存在
                //hub.server.fileExists("8e98d24306bd4ec4b154b0294fab0cae.doc").then(s => {
                //    alert(s);
                //})
                //文件是否打开
                //hub.server.isOpen("8e98d24306bd4ec4b154b0294fab0cae.doc").then(s => {
                //    alert(s);
                //})
            });

        });
    </script>

}
